package com.flea.hclv.controller;

import com.alibaba.fastjson.JSON;
import com.flea.hclv.model.entity.HTransferRecord;
import com.flea.hclv.service.HTransferRecordService;
import com.flea.hclv.util.ServerResponse;
import com.flea.system.platform.session.FleaOrgUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @program: project
 * @description: 转账记录（游客下单后组团社分期付款给供应商）
 * @author: shiliqiang
 * @create: 2018-11-02 00:01
 * @version: 1.0
 */
@Controller
@RequestMapping("/flea/hclv/transfer/record/")
public class HTransferRecordController {

    @Autowired
    private HTransferRecordService hTransferRecordService;

    @RequestMapping("save")
    @ResponseBody
    public ServerResponse<String> save(HttpServletRequest request, String model){
        String userId = FleaOrgUtils.getCurUserUuid(request);
        HTransferRecord hTransferRecord = JSON.parseObject(model,HTransferRecord.class);
        return hTransferRecordService.save(hTransferRecord,userId);
    }
    @RequestMapping("update")
    @ResponseBody
    public ServerResponse<String> update(HttpServletRequest request,String model) {
        String userId = FleaOrgUtils.getCurUserUuid(request);
        HTransferRecord hTransferRecord = JSON.parseObject(model, HTransferRecord.class);
        return hTransferRecordService.update(hTransferRecord, userId);
    }
    @RequestMapping("selectByOrderNo")
    @ResponseBody
    public ServerResponse<List<HTransferRecord>> selectByOrderNo(String orderNo) {
        return hTransferRecordService.selectByOrderNo(orderNo);
    }
    }
